define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {
		function get_data_mfacturer(result) {
			if(!false) {
				var result = '{"success":true,"msg":"","result":{"act":[{"act_id":"act_id_001","name":"新年促销","goods_count":10,"member_count":100,"start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","image":{"id":"001","image":"img/upload/pro-img01.jpg"}},{"act_id":"act_id_002","name":"新年促销","goods_count":10,"member_count":100,"start_time":"2017/01/01 09:00:00","end_time":"2017/01/31 09:00:00","image":{"id":"001","image":"img/upload/pro-img01.jpg"}}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}
		//返回信息
		return {

			get_detail: function(callback) {

				var data = new Object();
				data.top = ['进行中', '待审批', '已结束'];
				data.sliders = [1, 2, 3, 4];
				data.list = [1, 2, 3, 4, 5];

				if(callback)
					callback(data);
			},
			//制造商发起促销列表
			get_mfacturer: function(act_type,status,callback) {
				Http.post({
					method: 'marketing.promotion.getlist',
					form_type: 1,
					act_type: act_type,
					pagelimit:8,
					nPage:1,
					show_count:5,
					status:status
				}, function(result) {
					if(callback)
						callback(get_data_mfacturer(result).result);

				}, function(e) {

				}, function() {

				});

			},
			//代理商发起促销列表
			get_agential: function(act_type,status,callback) {
				Http.post({
					method: 'marketing.promotion.getlist',
					form_type: 2,
					act_type: act_type,
					pagelimit:8,
					nPage:1,
					show_count:5,
					status:status
				}, function(result) {
                   if(callback)
                   callback(get_data_mfacturer(result).result);

				}, function(e) {

				}, function() {

				});
			},
			//自己发起促销列表
			get_mine: function(act_type,status,callback) {
				Http.post({
					method: 'marketing.promotion.getlist',
					form_type: 3,
					act_type: act_type,
					pagelimit:8,
					nPage:1,
					show_count:5,
					status:status
				}, function(result) {
                    if(callback)
                    callback(get_data_mfacturer(result).result);
				}, function(e) {

				}, function() {

				});
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Sales", factory);
});